<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>@input的用法</title>
    <script src="js/vue.js"></script>
</head>
<body>
<div id="app">
    <input :value="filteredMessage" @input="filterInput">
    <p>过滤后的内容是：{{ filteredMessage }}</p>
</div>

<script>
    new Vue({
        el: '#app',
        data: {
            filteredMessage: ''
        },
        methods: {
            filterInput(event) {
                // 只保留数字
                this.filteredMessage = event.target.value.replace(/[^0-9]/g, '');
            }
        }
    });
</script>

</body>
</html>